<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of sfDeleteKTDCharacterTask
 *
 * @author Gael
 */
class sfDeleteKTDCharacterTask extends sfBaseTask {
       protected function configure(){
        $this->addOptions(array(
           new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The Application', 'frontend'),
           new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The Environment', 'prod'),
        ));
        $this->addArguments(array(
            new sfCommandArgument("pseudo", null, sfCommandArgument::REQUIRED)
        ));
        $this->namespace = "character";
        $this->name = "delete";
        $this->briefDescription = 'Delete a character';
        $this->detailedDescription = <<<EOF
            The [character:delete|INFO] task deletes a character from the database:
            [./symfony character:delete pseudo --env=prod |INFO]
EOF;
        }
        protected function execute($arguments = array(), $options = array()){
            $databaseManager = new sfDatabaseManager($this->configuration);
            $q = Doctrine_Query::create()->delete("KTDCharacter c")->where("c.pseudo = ?", $arguments["pseudo"]);
            if($q->execute())
                $this->logSection("Doctrine", sprintf("Removed the character %s", $arguments["pseudo"]));
            else
                $this->logSection("Doctrine", sprintf("Failed to remove the character %s", $arguments["pseudo"]));
        }
}
?>
